<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java接口与抽象类深度解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            overflow: hidden;
            position: relative;
        }
        
        .code-block::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 40px;
            background: #2d2d2d;
            display: flex;
            align-items: center;
            padding: 0 15px;
        }
        
        .code-content {
            padding: 60px 30px 30px;
            overflow-x: auto;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 24px;
            margin-bottom: 20px;
        }
        
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #667eea, transparent);
            margin: 60px 0;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeIn {
            animation: fadeInUp 0.8s ease-out;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 8px;
            margin-top: -8px;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .comparison-table {
            background: white;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .comparison-table th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            font-weight: 600;
        }
        
        .comparison-table td {
            padding: 20px;
            border-bottom: 1px solid #f0f0f0;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 40px 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-32 relative overflow-hidden">
        <div class="absolute inset-0 opacity-10">
            <div class="absolute top-10 left-10 w-64 h-64 bg-white rounded-full filter blur-3xl"></div>
            <div class="absolute bottom-10 right-10 w-96 h-96 bg-purple-300 rounded-full filter blur-3xl"></div>
        </div>
        <div class="container mx-auto px-6 relative z-10">
            <div class="max-w-4xl mx-auto text-center animate-fadeIn">
                <h1 class="text-5xl md:text-7xl font-bold mb-6">
                    Java 接口与抽象类
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    深入理解面向对象编程的两大核心抽象机制
                </p>
                <div class="flex justify-center space-x-4">
                    <span class="inline-flex items-center px-4 py-2 bg-white bg-opacity-20 rounded-full">
                        <i class="fas fa-code mr-2"></i> 设计模式
                    </span>
                    <span class="inline-flex items-center px-4 py-2 bg-white bg-opacity-20 rounded-full">
                        <i class="fas fa-layer-group mr-2"></i> 架构思维
                    </span>
                    <span class="inline-flex items-center px-4 py-2 bg-white bg-opacity-20 rounded-full">
                        <i class="fas fa-puzzle-piece mr-2"></i> 最佳实践
                    </span>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto">
                <div class="bg-white rounded-2xl shadow-xl p-10 animate-fadeIn">
                    <p class="text-lg leading-relaxed text-gray-700">
                        <span class="drop-cap">在</span>Java的世界里，接口和抽象类如同建筑设计中的蓝图和框架，它们是实现抽象化和多态性的重要工具。虽然两者都服务于抽象的目的，但它们在设计理念、使用场景和实现方式上存在着显著的差异。理解这些差异，对于构建优雅、可扩展的软件架构至关重要。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Core Concepts -->
    <section class="py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="text-4xl font-bold text-center mb-16 text-gradient">核心概念解析</h2>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <!-- Interface Card -->
                    <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                        <div class="feature-icon">
                            <i class="fas fa-plug"></i>
                        </div>
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">接口 Interface</h3>
                        <p class="text-gray-600 mb-6">
                            接口是一种特殊的引用类型，定义了一组方法规范，但不包含具体实现。它是一份契约，规定了实现类必须遵守的行为准则。
                        </p>
                        <div class="space-y-3">
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">所有方法默认为 public abstract</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">只能包含静态常量（public static final）</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">支持多重继承，一个类可实现多个接口</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">Java 8+ 支持默认方法和静态方法</span>
                            </div>
                        </div>
                    </div>

                    <!-- Abstract Class Card -->
                    <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                        <div class="feature-icon">
                            <i class="fas fa-cubes"></i>
                        </div>
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">抽象类 Abstract Class</h3>
                        <p class="text-gray-600 mb-6">
                            抽象类是不能被实例化的类，可以包含抽象方法和具体实现。它为相关类提供了共同的基础实现和行为框架。
                        </p>
                        <div class="space-y-3">
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">可包含构造方法、实例变量和具体方法</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">只支持单继承，一个类只能继承一个抽象类</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">可使用任何访问修饰符（public, protected, private）</span>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <span class="text-gray-700">提供部分实现，减少代码重复</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Design Philosophy -->
    <section class="py-20 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="text-4xl font-bold text-center mb-16 text-gradient">设计哲学与应用场景</h2>
                
                <div class="grid md:grid-cols-2 gap-12">
                    <div class="space-y-8">
                        <div class="bg-white rounded-xl p-6 shadow-lg">
                            <h4 class="text-xl font-bold mb-3 flex items-center">
                                <i class="fas fa-lightbulb text-yellow-500 mr-3"></i>
                                接口的设计哲学
                            </h4>
                            <p class="text-gray-600 mb-4">
                                接口强调"能做什么"而非"是什么"。它定义了对象的能力和行为规范，让不同的类可以以各自的方式实现相同的功能。
                            </p>
                            <div class="bg-purple-50 rounded-lg p-4">
                                <p class="text-sm text-purple-700">
                                    <strong>适用场景：</strong>当需要为不相关的类定义共同行为，或需要实现多重继承时，接口是最佳选择。
                                </p>
                            </div>
                        </div>
                        
                        <div class="bg-white rounded-xl p-6 shadow-lg">
                            <h4 class="text-xl font-bold mb-3 flex items-center">
                                <i class="fas fa-sitemap text-blue-500 mr-3"></i>
                                抽象类的设计哲学
                            </h4>
                            <p class="text-gray-600 mb-4">
                                抽象类强调"是什么"的关系。它为一组相关的类提供共同的基础实现，定义了类的本质属性和共享行为。
                            </p>
                            <div class="bg-blue-50 rounded-lg p-4">
                                <p class="text-sm text-blue-700">
                                    <strong>适用场景：</strong>当多个相关类需要共享代码实现，或需要定义模板方法时，抽象类更为合适。
                                </p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-white rounded-2xl shadow-xl p-8">
                        <h4 class="text-xl font-bold mb-6 text-center">架构关系图</h4>
                        <div class="mermaid">
                            graph TD
                                A[软件设计需求] --> B{选择抽象机制}
                                B -->|定义行为规范| C[接口]
                                B -->|共享实现代码| D[抽象类]
                                C --> E[多重实现]
                                C --> F[松耦合设计]
                                D --> G[代码复用]
                                D --> H[模板方法]
                                E --> I[策略模式]
                                F --> J[依赖倒置]